package com.chenbei.controller.admin.erp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenbei.common.domain.vo.ApiResponse;
import com.chenbei.common.domain.vo.Pagination;
import com.chenbei.common.util.ApiResponseUtil;
import com.chenbei.erp.domain.Warehouse;
import com.chenbei.erp.service.IWarehouseService;
import com.chenbei.erp.vo.req.WarehouseReq;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "仓库管理")
@RestController("WMSWarehouse")
@RequestMapping("/admin/erp/warehouse")
public class WarehouseController {

    @Autowired
    private IWarehouseService warehouseService;

    @Operation(summary = "新增仓库")
    @PostMapping("add")
    public ApiResponse<Object> add(@RequestBody @Valid Warehouse Warehouse) {
        warehouseService.add(Warehouse);
        return ApiResponseUtil.success();
    }

    @Operation(summary = "更新仓库")
    @PostMapping("update")
    public ApiResponse<Object> update(@RequestBody @Valid Warehouse Warehouse) {
        warehouseService.update(Warehouse);
        return ApiResponseUtil.success();
    }

    @Operation(summary = "仓库分页列表")
    @GetMapping("pageList")
    public ApiResponse<Pagination<Warehouse>> pageList(WarehouseReq WarehouseReq) {
        Page<Warehouse> warehousePage = warehouseService.pageList(WarehouseReq);
        return ApiResponseUtil.success(warehousePage);
    }

    @Operation(summary = "删除仓库")
    @PostMapping("deleteById/{id}")
    public ApiResponse<Object> delete(@PathVariable Long id) {
        warehouseService.deleteId(id);
        return ApiResponseUtil.success();
    }
}
